package com.caiback.mapper;

import com.caiback.pojo.FindPost;
import com.caiback.pojo.MarketPost;
import com.caiback.pojo.Post;
import com.caiback.pojo.RecruitPost;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface PostMapper {
    @Insert("${sql}")
    int createPost(@Param("sql") String sql,@Param("post") Post post);

    @Select("SELECT * FROM postsfind")
    List<Post> getPostsFind();

    @Select("SELECT * FROM postsrecruit")
    List<Post> getPostsRecruit();

    @Select("SELECT * FROM postsmarket")
    List<Post> getPostsMarket();

    @Select("SELECT * FROM postsmarket WHERE user_id = #{userId}")
    List<MarketPost> getPostsPageMarket( Integer userId);

    @Select("SELECT * FROM postsfind WHERE user_id = #{userId}")
    List<FindPost> getPostsPageFind(Integer userId);

    @Select("SELECT * FROM postsrecruit WHERE user_id = #{userId}")
    List<RecruitPost> getPostsPageRecruit(Integer userId);

    @Delete("DELETE FROM ${postsname} WHERE id = #{id}")
    int deletePost(Integer id, String postsname);
}
